////////////////////////////////////////////////////////////////////////////////
//
//  Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
//  All Rights Reserved. The following is Source Code and is subject to all
//  restrictions on such code as contained in the End User License Agreement
//  accompanying this product.
//
////////////////////////////////////////////////////////////////////////////////

package mx.charts.events
{

import flash.events.Event;
import flash.events.MouseEvent;
import mx.charts.LegendItem;

/**
 *   The LegendMouseEvent class represents event objects that are specific to the chart legend components.
 *   such as when a legend item is clicked on.
 */
public class LegendMouseEvent extends MouseEvent
{
    include "../../core/Version.as";

    //--------------------------------------------------------------------------
    //
    //  Class constants
    //
    //--------------------------------------------------------------------------

	/**
	 *  Event type constant; indicates that the user clicked the mouse button
	 *  over a legend item.
	 */
	public static const ITEM_MOUSE_DOWN:String = "itemMouseDown";
	
	/**
	 *  Event type constant; indicates that the user released the mouse button
	 *  while over  a legend item.
	 */
	public static const ITEM_MOUSE_UP:String = "itemMouseUp";
	
	/**
	 *  Event type constant; indicates that the user rolled the mouse pointer
	 *  away from a legend item.
	 */
	public static const ITEM_MOUSE_OUT:String = "itemMouseOut";
	
	/**
	 *  Event type constant; indicates that the user rolled the mouse pointer
	 *  over  a legend item.
	 */
	public static const ITEM_MOUSE_OVER:String = "itemMouseOver";
	
	/**
	 *  Event type constant; indicates that the user clicked the mouse button
	 *  over a legend item.
	 */
	public static const ITEM_CLICK:String = "itemClick";

    //--------------------------------------------------------------------------
    //
    //  Class methods
    //
    //--------------------------------------------------------------------------

	/**
	 *  @private
	 */
	private static function convertType(baseType:String):String
	{
		switch (baseType)
		{
			case MouseEvent.CLICK:
			{
				return ITEM_CLICK;
			}
				
			case MouseEvent.MOUSE_DOWN:
			{
				return ITEM_MOUSE_DOWN;
			}
				
			case MouseEvent.MOUSE_UP:
			{
				return ITEM_MOUSE_UP;
			}
				
			case MouseEvent.MOUSE_OVER:
			{
				return ITEM_MOUSE_OVER;
			}
				
			case MouseEvent.MOUSE_OUT:
			{
				return ITEM_MOUSE_OUT;
			}
		}
		
		return baseType;
	}

    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------

	/**
	 *  Constructor.
	 *
	 *  @param triggerEvent The MouseEvent that triggered this LegentMouseEvent.
	 *
	 *  @param item The item in the Legend on which this event was triggered.
	 */
	public function LegendMouseEvent(triggerEvent:MouseEvent, item:LegendItem)
	{	
		super(convertType(triggerEvent.type), triggerEvent.bubbles,
			  triggerEvent.cancelable, triggerEvent.localX, triggerEvent.localY,
			  triggerEvent.relatedObject, triggerEvent.ctrlKey,
			  triggerEvent.altKey, triggerEvent.shiftKey,
			  triggerEvent.buttonDown, triggerEvent.delta);		

		this.item = item;
	}
	
    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------

    //----------------------------------
	//  item
    //----------------------------------

	[Inspectable(environment="none")]

	/**
	 *  The item in the Legend on which this event was triggered.
	 */
	public var item:LegendItem;

    //--------------------------------------------------------------------------
    //
    //  Overridden methods: event
    //
    //--------------------------------------------------------------------------

	/**
	 *	@private
	 */
	override public function clone():Event
	{
		return new LegendMouseEvent(this, item);
	}
}

}
